/**
* All Rights Reserved , Copyright (C) 2022 , 青岛鼎信通讯股份有限公司
*
* MpmCustomerTaskService
* 项目策划-客户任务子表
*
* 修改纪录
* 2022-03-10 版本：1.0 houyuhang 创建。
* @version 版本：1.0
* @author 作者：houyuhang
* 创建日期：2022-03-10
*/
package com.topscomm.mpm.service.impl;

import com.topscomm.mpm.pojo.MpmProjectPlanEntity;
import com.topscomm.pub.util.ConvertUtil;
import com.topscomm.pub.util.StringBufferProxy;
import com.topscomm.pub.vo.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Service;

import com.topscomm.mpm.service.IMpmCustomerTaskService;
import com.topscomm.mpm.service.impl.auto.MpmCustomerTaskServiceAuto;
import org.springframework.util.CollectionUtils;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

@Service(value = "mpmCustomerTaskService")
@Scope(value = "singleton")
public class MpmCustomerTaskService extends MpmCustomerTaskServiceAuto implements IMpmCustomerTaskService {
    @Autowired
    private MpmProjectPlanService mpmProjectPlanService;
    /**
     * @author: houyuhang
     * @date: 2022-03-21
     * @param: paraMap
     * @description: 系统部监管加载客户任务相关信息
     * @return: List<Object>
     * @modify:
     */
    public List<Map<String, Object>> queryCustomerTaskForSystem(Map<String, Object> paraMap) {
        String projectcode = ConvertUtil.convertToString(paraMap.get("projectcode"));
        StringBufferProxy sql = new StringBufferProxy();
        sql.appendSingle("enabled = 1 and state = 9 and projectcode = '{0}' ", projectcode);
        List<MpmProjectPlanEntity> mpmProjectPlanEntities = mpmProjectPlanService.queryByWhere(sql.toString());
        if(CollectionUtils.isEmpty(mpmProjectPlanEntities)) {
            return new ArrayList<>();
        }
        String planid = ConvertUtil.convertToString(mpmProjectPlanEntities.get(0).getId());
        sql.clear();
        sql.appendSingle(" planid = '{0}' ",planid);
        List<Map<String,Object>> tempList = this.queryMapByWhere(sql.toString());
        return tempList;
    }
}
